<template>
  <div class="app-container">
    <header>
      <p class="title">POPULAR ITEMS</p>
    </header>
    <main>
      <div class="left">
        <div v-for="(item, index) in menu_list" :key="index" class="game">
          <div class="image">
            <img v-lazy="item.image" alt="" @click="toPropsList(item)" />
          </div>
          <p class="name" @click="toPropsList(item)">{{ item.name }}</p>
        </div>
      </div>
      <div class="right">
        <div class="tit">Read Latest Gaming News</div>
        <div class="right-item">
          <div class="name">MARVEL RIVALS</div>
          <div class="sub">
            Marvel Rivals Teases Human Torch and The Thing Gameplay
          </div>
          <div class="mes">
            Marvel Rivals has teased their two new heroes coming to the
            mid-season update: The Human Torch and The Thing from the Fantastic
            4. Here’s everything you need to [...]
          </div>
          <div class="author">By Elijah | February 19th, 2025</div>
          <div class="name second">OTHERS</div>
          <div class="sub">
            Complete Avowed Unique Items Table List and Locations
          </div>
          <div class="mes">
            Avowed has no shortage of unique items you can find in your travels,
            and some of them can significantly boost your build. However,
            finding them will require eff [...]
          </div>
          <div class="author">By Dillan | February 18th, 2025</div>
        </div>
      </div>
    </main>
    <!-- <div class="line"></div> -->
  </div>
</template>

<script setup>
import { categories, productList } from "@/api/product";
import { useRoute, useRouter } from "vue-router";
import { ref } from "vue";

const route = useRoute();
const router = useRouter();

// 获取分类列表
const menu_list = ref([]);
const getProductList = () => {
  categories({
    parent_ids: [100306, 100307, 100308],
  }).then((res) => {
    menu_list.value = res.data;
  });
};
getProductList();

// 跳转道具列表
const toPropsList = (item) => {
  router.push({
    path: "/propsList",
    query: { id: item.id },
  });
};
</script>

<style lang="scss" scoped>
.app-container {
  margin-top: 20px;

  .title {
    padding: 40px 0 20px 0;
    background: linear-gradient(
      to top,
      rgba(255, 255, 255, 0),
      rgba(0, 107, 255, 0.1) 100%
    );
    font-size: 58px;
    line-height: 57px;
    font-weight: bold;
    color: #fff;
  }
  main {
    padding-top: 50px;
    display: flex;
    .left {
      width: 900px;
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      background: #263044;
      border-radius: 10px;
      padding-right: 10px;
      .game {
        .name {
          font-size: 18px;
          color: #fff;
          margin: 10px 0;
          text-align: center;
          cursor: pointer;
        }
        .name:hover{
          color:#ffa300;
          font-weight: bold;
        }
        .image {
          margin-top: 10px;
          cursor: pointer;
        }
        &:nth-child(1) {
          .image {
            margin-top: 0px;
          }
          img {
            width: 580px;
            height: auto;
          }
          grid-row: 1/3;
          grid-column: 1/3;
          .name {
            margin-top: 30px;
          }
        }
      }
    }
    .right {
      flex: 1;
      padding-left: 30px;
      padding-top: 8px;
      .tit {
        font-size: 25px;
        color: #fff;
        margin-bottom: 20px;
      }
      .right-item {
        background: #263044;
        padding: 20px 20px;
        border-radius: 10px;
        .name {
          font-size: 14px;
          color: #ffa330;
        }
        .second {
          margin-top: 20px;
        }
        .sub {
          font-size: 20px;
          color: #fff;
          margin: 10px 0;
        }
        .mes {
          font-size: 15px;
          color: #8f939a;
          line-height: 20px;
        }
        .author {
          font-size: 14px;
          color: #fff;
          margin-top: 18px;
        }
      }
    }
  }
  .line {
    width: 2px;
    height: 50px;
    background: #ffa300;
    margin: 40px auto;
    margin-bottom: 40px;
  }
}
</style>
